import { createRouter, createWebHistory } from 'vue-router'
import page from './page.js'

export const constantRoutes = page.basePage

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = page.dynamicPage

const router = createRouter({
    history: createWebHistory(),
    routes: constantRoutes,
    // 刷新页面，复原滚动
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return {top: 0}
        }
    },
})

export default router
